package realtime.util;

import org.apache.flink.streaming.api.windowing.windows.TimeWindow;

import java.lang.reflect.Field;

public class MyWindowFunction {
    public static <T> void getWindowFunction(TimeWindow window, T t) throws IllegalAccessException, NoSuchFieldException {
        Class<?> clz = t.getClass();

        Field stt = clz.getDeclaredField("stt");
        stt.setAccessible(true);
        stt.set(t,DateFormatUtil.toYmdHms(window.getStart()));

        Field edt = clz.getDeclaredField("edt");
        edt.setAccessible(true);
        edt.set(t,DateFormatUtil.toYmdHms(window.getEnd()));

        Field ts = clz.getDeclaredField("ts");
        ts.setAccessible(true);
        ts.set(t,System.currentTimeMillis());

    }


}
